package com.suyuan.service.impl;


import com.suyuan.dao.ProducetypeInfoMapper;
import com.suyuan.entity.ProducetypeInfo;
import com.suyuan.service.ProductType2Service;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 *商城后台系统管理
 */
@Service("productType2ServiceImpl")
public class ProductType2ServiceImpl implements ProductType2Service {

    @Resource
    private ProducetypeInfoMapper producetypeInfoMapper;


    public List<ProducetypeInfo> findAllType() {
        return  producetypeInfoMapper.selectByExample(null);
    }

    public void deleteType(Integer id) {
        producetypeInfoMapper.deleteByPrimaryKey(id);
    }

    public ProducetypeInfo selectTypeByGid(Integer id) {
        return producetypeInfoMapper.selectByPrimaryKey(id);
    }

    /**
     *商城后台 更新产品类信息
     * @param producetypeInfo
     */
    public void updateTypeInfo(ProducetypeInfo producetypeInfo) {
        ProducetypeInfo curProduceTypeInfo = producetypeInfoMapper.selectByPrimaryKey(producetypeInfo.getGid());
        curProduceTypeInfo.setRecaddtime(producetypeInfo.getRecaddtime());
        curProduceTypeInfo.setCreator(producetypeInfo.getCreator());
        curProduceTypeInfo.setProctypename(producetypeInfo.getProctypename());
        curProduceTypeInfo.setRecmemo(producetypeInfo.getRecmemo());
        curProduceTypeInfo.setState(producetypeInfo.getState());
        producetypeInfoMapper.updateByPrimaryKey(curProduceTypeInfo);
    }

    /**
     * 商城后台更新商品类型信息
     * @param producetypeInfo
     */
    public void addProduceTypeInfo(ProducetypeInfo producetypeInfo) {
        producetypeInfo.setRecaddtime(new Date());
        producetypeInfoMapper.insertSelective(producetypeInfo);
    }
}
